<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<meta name="keywords" content="(www.eblog.site),博文分享，技术博文，影音推荐，美食分享，生活技巧，笑话大全"/>
<meta name="description" content="eBlog分享网(www.eblog.site)为广大朋友们提供有技术的博文，最新最热门的电影音乐。看到就流口水的美食，各种生活技巧，笑喘不过气的笑话！ "/>
<title>首页</title>
<link rel="shortcut icon" href="assets/manager/favicon.ico" />  
<link href="assets/css/common.css" type="text/css" rel="stylesheet" />
<link href="assets/css/style.css" type="text/css" rel="stylesheet" />
</head>

<body>
<!-- common -->
<%@ include file="header.jsp"%>
<!-- common -->
<!-- wrap -->
<div class="wrap">
    <!-- content -->
    <div class="content">
        <!-- left -->
        <section id="ileft" class="lfloat">
            <ul id="LitemUl">
            </ul>
            <div class="pageBox"><p></p></div>
        </section>
        <!-- left -->
        <!-- right -->
        <section id="iright" class="rfloat">
            <div class="Ritem">
                <h3>阅读排行榜</h3>
                <ul class="RitemUl" id="readTop">
                </ul>
            </div>
            <div class="Ritem">
                <h3>推荐排行榜</h3>
                <ul class="RitemUl" id="tuijianTop">
                </ul>
            </div>
        </section>
        <!-- right -->
    </div>
    <!-- content -->
    <!-- copyright -->
    <%@ include file="footer.jsp"%>
    <!-- copyright -->
</div>
<!-- wrap -->
<script type="text/javascript" src="assets/scripts/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="assets/scripts/hr-jquery.js"></script>
<script src="assets/manager/js/pageBox.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var $page=1;
	var $pageSize=6;
	var $tag = null;
	var $title = null;
	var $author = null;
	
	getArticles($page,$pageSize,$tag,$title,$author);
	function getArticles(rpage,rpageSise,rqtag,rqtitle,rqauthor){
		$.post("mgGetArticleByAuthor",
			{page:rpage,pageSize:rpageSise,tag:rqtag,title:rqtitle,author:rqauthor},
			function(data){
			pageBox(data.pageInfo);
    		var $LitemUl = $("#LitemUl");
    		$("#LitemUl li").remove();
    		for(var i=0;i<data.pageInfo.list.length;i++){
        		var $article = data.pageInfo.list[i];
        		var $id = $article.id;
        		var $postD = $article.postD.split(".")[0];
        		var $li = $('<li class="Litem">'
                        	+ '<h2><a href="content?id='+$id+'">' + $article.title + '</a></h2>'
                        	+ '<p class="intro">' + $article.intro + '</p>'
                        	+ '<dl class="info">'
                        		+ '<dt><a href="center?author='+$article.author+'"><img src="'+$article.userPic+'" alt="头像"></a></dt>'
                        		+ '<dd class="userName"><a href="center?author='+$article.author+'">' + $article.author + '</a></dd>'
                        		+ '<dd class="postDate">' + $postD + '</dd>'
                        		+ '<dd class="tag">'+$article.tag+'(<em>'+$article.type+'</em>)</dd>'
                        		+ '<dd class="readNum rfloat">'
                        		+ '<i class="read"></i><span class="readN">'+$article.readN+'</span>'
                        		+ '<i class="tuijian"></i><span class="tuijianN">'+$article.recommendN+'</span>'
                        	+ '</dd>'
                        	+ '</dl>'
                        + '</li>');
    			$LitemUl.append($li);
    			setTimeout(function(){$("#menuBox a:first").addClass("click");},80);
    		}
    	});
	}
	//分页
    $(".pageBox").on("click","a",function(){
    	var $cPage = $(this).attr("data-page");
    	var $maxPage =  $(".pageBox p").find("a:last").html();
    	if($cPage  == 0 || $(this).attr("class") == "active"){
    		return false;
    	}else if($page == $maxPage && ($(this).html() == "下一页" || $(this).html() == "尾页")){
    		return false;
    	}else if($page == 1 && ($(this).html() == "上一页" || $(this).html() == "首页")){
    		return false;
    	}
    	else{
    		$page = $cPage;
    		getArticles($page,$pageSize,$tag,$title,$author);
    	} 
    });
  	//分页
  	
  	//阅读top
  	$.get("readTop",function(data){
  		var $articles = data.pageInfo.list;
  		$("#readTop li").remove();
  		var $readTopBox = $("#readTop");
  		for(var i=0;i<$articles.length;i++){
  			var $li = $('<li><a href="content?id='+$articles[i].id+'">'+$articles[i].title+'</a></li>');
  			$readTopBox.append($li);
  		}
  	});
  	//阅读top
  	//推荐Top
  	$.get("tuijianTop",function(data){
  		var $articles = data.pageInfo.list;
  		$("#tuijianTop li").remove();
  		var $tuijianTopBox = $("#tuijianTop");
  		for(var i=0;i<$articles.length;i++){
  			var $li = $('<li><a href="content?id='+$articles[i].id+'">'+$articles[i].title+'</a></li>');
  			$tuijianTopBox.append($li);
  		}
  	});
  	//推荐Top
});
</script>
</body>
</html>
